

import requests

from api.basic.base import RequestBase
class Url:
    _URL_COUPON_SELECT = "/adminapi/shop/goods/coupon"
    _URL_COUPON_ADD = "/adminapi/shop/goods/coupon"
    _URL_COUPON_EDIT = "/adminapi/shop/goods/coupon/edit"
    _URL_COUPON_INVALID = "/adminapi/shop/goods/coupon/invalid"
    _URL_COUPON_DLE = "/adminapi/shop/goods/coupon"


class Marketing(RequestBase,Url):
    def goods_coupon_select(self):
        return self._get(self.goods_coupon_select.__name__,self._URL_COUPON_SELECT)
    def goods_coupon_add(self,title,price):
        data = {
            "json": {
                'title': title,
                'price': price,
                'type': 1,
                'limit': 2,
                'receive_type': 1,
                'remain_count': 1000,
                'threshold': 2,
                'limit_count': 1,
                'min_condition_money': 1,
                'length': 30,
                'receive_type_time': 2,
                'valid_type': 1,
                'receive_time': [
                    '2025-03-14T09:01:38.326Z',
                    '2025-04-13T09:01:38.326Z',
                ],
                 'valid_time': '2025-04-13T09:01:38.326Z',

            }
        }
        return self._post(self.goods_coupon_add.__name__,self._URL_COUPON_ADD,data)

    def goods_coupon_edit(self,coupon_Id,title,price):
        data = {

                'title': title,
                'price': price,
                'type': 1,
                'limit': 2,
                'receive_type': 1,
                'remain_count': 1000,
                'threshold': 2,
                'limit_count': 1,
                'min_condition_money': '0.00',
                'length': 30,
                'receive_type_time': 2,
                'valid_type': 1,
                'receive_time': [
                    '2025-03-15T01:12:26.539Z',
                    '2025-04-14T01:12:26.539Z',
                ],
                'valid_time': '2025-04-13 17:01:38',
                'id': coupon_Id,
                'start_time': 0,
                'end_time': 0,
                'receive_count': 0,
                'status': 1,
                'create_time': '2025-03-14 17:53:06',
                'valid_start_time': '2025-03-14 17:53:06',
                'valid_end_time': '2025-04-13 17:01:38',
                'sort': 0,
                'receive_status': 1,
                'sum_count': '不限量',
                'receive_use_count': 0,
                'receive_expire_count': 0,
        }
        return self._put(self.goods_coupon_edit.__name__,self._URL_COUPON_EDIT + f"/{coupon_Id}",data)

    def goods_coupon_invalid(self,coupon_Id):
        data = {'showSuccessMessage': True}
        return self._put(self.goods_coupon_invalid.__name__,self._URL_COUPON_INVALID + f"/{coupon_Id}",data)
    def goods_coupon_del(self,coupon_Id):
        return self._delete(self.goods_coupon_del.__name__,self._URL_COUPON_SELECT + f"/{coupon_Id}")
    def goods_coupon_records(self):
        pass
    def goods_coupon_detail(self):
        pass

if __name__ == '__main__':
    obj = Marketing()
    obj.goods_coupon_select()